try
    Screen('flip',w)
catch
    try
        Screen('flip',frame.ptr)
    catch
        try
            Screen('flip',window)
        catch
            try
                Screen('flip',10)
            end
        end
    end
end


